// @ts-nocheck
/**
 * @Date: 2022-04-11 11:14:41
 * @LastEditors: sailornpg
 * @LastEditTime: 2022-04-21 12:51:50
 * @FilePath: \weibo-api\routes\blogs.js
 * @Description: 博客路由
 */
const router = require("koa-router")();
const {
  createBlog,
  getBlogList,
  deleteBlog,
  blogDetail,
} = require("../controller/blogCtl");
const { getSquareBlogList } = require("../cache/blogCache");
const { auth } = require("../middleware/loginCheck");
const { blogValidator } = require("../middleware/validator");
const { checkBlogIsOwn } = require("../middleware/check");
const { getBlogLikeCount } = require("../controller/likeCtl");
router.prefix("/api/blogs");
//创建微博内容
router.post("/", auth, blogValidator, createBlog);
//获取博客列表
router.get("/", getBlogList);
//获取广场微博列表
// router.get("/square", async (ctx, next) => {
//   let { currentPage = 1, pageSize = 5 } = ctx.query;
//   console.log("参数是", currentPage, pageSize);
//   let res = await getSquareBlogList(parseInt(currentPage), parseInt(pageSize));
//   ctx.body = new SuccessModel(res);
// });
router.get("/square", getBlogList);
//获取博客详情
router.get("/detail/:blogId/:userId", blogDetail);
//删除微博
router.delete("/:id", auth, checkBlogIsOwn, deleteBlog);
//获取点赞数量
router.get("/like/:blogId", getBlogLikeCount);
module.exports = router;
